package main

import (
	"container/list"
	"fmt"
)

func main() {
	fmt.Println("=====list 双向链表=====")
	l := list.New()
	l.PushBack(2)
	first := l.PushFront(1)
	l.PushBack(3)
	for item := l.Front(); item != nil; item = item.Next() {
		fmt.Print(item.Value, " ")
	}
	fmt.Println(";")
	fmt.Println("first:", first.Value)
	fmt.Println("len:", l.Len())

	l.InsertBefore(-1, first)
	l.Remove(first)
	for item := l.Front(); item != nil; item = item.Next() {
		fmt.Print(item.Value, " ")
	}
	fmt.Println(";")

	l.Init()
	for item := l.Front(); item != nil; item = item.Next() {
		fmt.Print(item.Value, " ")
	}
	fmt.Println(";")
}
